package com.henghai.zhenxuan.ui.page.adapter;

import android.content.Context;
import androidx.recyclerview.widget.RecyclerView;

import com.blankj.utilcode.util.ResourceUtils;
import com.henghai.zhenxuan.data.bean.AdoptListBean;
import com.henghai.zhenxuan.R;
import com.henghai.zhenxuan.databinding.AdapterAdoptItemBinding;
import com.kunminx.binding_recyclerview.adapter.SimpleDataBindingAdapter;

public class AdoptAdapter extends SimpleDataBindingAdapter<AdoptListBean.RowsDTO, AdapterAdoptItemBinding> {

    public AdoptAdapter(Context context) {
        super(context, com.henghai.zhenxuan.R.layout.adapter_adopt_item, DiffUtils.getInstance().getAdoptItemCallback());
    }


    @Override
    protected void onBindItem(AdapterAdoptItemBinding binding, AdoptListBean.RowsDTO item, RecyclerView.ViewHolder holder) {
        binding.setAdopt(item);
        binding.btnLingyang.setOnClickListener(v -> mItemBtClickListener.onItemDelClick(item, holder.getBindingAdapterPosition()));
        if (item.getPetTag()!= null){
            switch (item.getPetTag()) {
                case "1":
                    binding.tvGooseTag.setText("活力之星");
                    binding.tvGooseTag.setBackgroundDrawable(ResourceUtils.getDrawable(R.drawable.btn_pink_radius_30));
                    break;
                case "2":
                    binding.tvGooseTag.setText("人气之星");
                    binding.tvGooseTag.setBackgroundDrawable(ResourceUtils.getDrawable(R.drawable.btn_purple_radius_30));
                    break;
                case "3":
                    binding.tvGooseTag.setText("魅力之星");
                    binding.tvGooseTag.setBackgroundDrawable(ResourceUtils.getDrawable(R.drawable.btn_blueradius_30));
                    break;
            }
        }
    }

    private OnItemBtClickListener mItemBtClickListener;

    public void setOnItemBtClickListener(OnItemBtClickListener l) {
        this.mItemBtClickListener = l;
    }

    public interface OnItemBtClickListener {
        void onItemDelClick(AdoptListBean.RowsDTO adoptBean, int postion);
    }
}
